package com.seguros.servicios.controller;

import java.util.Collection;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;

import com.seguros.servicios.domain.Contacto;
import com.seguros.servicios.service.ContactoService;

@Controller
@RequestMapping("/contacto")
public class ContactoController {

	@Autowired
	private ContactoService contactoService;

	@RequestMapping(method = RequestMethod.GET)
	public @ResponseBody
	Collection<Contacto> findAll() {
		return contactoService.findAll();
	}

	@RequestMapping(method = RequestMethod.POST)
	@ResponseStatus(value = HttpStatus.CREATED)
	public @ResponseBody
	Contacto guardarContacto(@RequestBody Contacto contacto) {
		return contactoService.guardar(contacto);
	}
}
